//
//  FromQueryDetController.m
//  PropertyMananger
//
//  Created by bh on 17/2/28.
//  Copyright © 2017年 BH. All rights reserved.
//

#import "FromQueryDetController.h"
#import "CheckFormDetailCell.h"

@interface FromQueryDetController ()

@end

@implementation FromQueryDetController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initTitleViewName:@"抄表查询详情"];
    
    [self initTableViewWithView:self.view frame:CGRectMake(0, 0, BHscreenW, BHscreenH -64) isGroup:NO];
    
    self.tableView.backgroundColor = BHGrayColor;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 2;
    
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (section == 0) {
        
        return 8;
    }else{
        
        return 2;
    }
    
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    CheckFormDetailCell * cell = [CheckFormDetailCell cellWithTableView:tableView];
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            
            self.titleStr = @"抄表类型:";
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.MeterReadingType];
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }else if (indexPath.row == 1){
            
            self.titleStr = @"楼栋:";
            if (self.model.unitname == nil) {
                
                self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.buildname];
            }else{
            
                self.pingjieStr = [NSString stringWithFormat:@"%@  %@ %@",self.titleStr,self.model.buildname,self.model.unitname];
            }
            
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }else if (indexPath.row == 2){
            self.titleStr = @"房间号:";
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.RoomName];
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }else if (indexPath.row == 3){
            
            self.titleStr = @"抄表状态:";
            if (self.model.StatusName == nil) {
                
                self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,@""];
            }else{
             self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.StatusName];
            }
           
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.textColor = [UIColor redColor];
            cell.infoLabel.attributedText = self.stra;
            
        }else if (indexPath.row == 4){
            
            self.titleStr = @"抄表日期:";
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.MeterReadingTime];
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }else if (indexPath.row == 5){
            
            self.titleStr = @"抄表周期:";
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.ChargeBillCycle];
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }else if (indexPath.row == 6){
            
            self.titleStr = @"业主姓名:";
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.OwnerName];
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
        }else if (indexPath.row == 7){
            
            self.titleStr = @"抄表人:";
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.MeterReadingMan];
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }
        
    }else if (indexPath.section == 1){
        
        if (indexPath.row == 0) {
            
            self.titleStr = @"上次抄表读数:";
            
            if (self.model.LastCopyNumber == nil) {
                
              self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,@""];
            }else{
            
            self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.LastCopyNumber];
                
            }
            
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
        }else if (indexPath.row == 1){
            
            self.titleStr = @"本次抄表读数:";
            if (self.model.CurrentMeterReading == nil) {
                
                self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,@""];
                
            }else{
                
                self.pingjieStr = [NSString stringWithFormat:@"%@  %@",self.titleStr,self.model.CurrentMeterReading];
            }
            self.stra = [[NSMutableAttributedString alloc]initWithString:self.pingjieStr];//可随意拼接字符串
            [self.stra addAttributes:@{NSFontAttributeName:BHFont(15),NSForegroundColorAttributeName:BHColor(102, 102, 102)} range:NSMakeRange(0, self.titleStr.length)];
            cell.infoLabel.attributedText = self.stra;
            
        }
        
    }
    return cell;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (section == 0) {
        
        return 0.001f;
    }
    return 15;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}


@end
